package com.thelongrhode.core;

import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;

public final class CollectionUtils {

	public static <E,F> List<F> findAllValuesForKey(Map<E, F> map, E key) {
		if (map == null || key == null)
			return null;
		Set<E> keySet = map.keySet();
		List<F> values = new LinkedList<F>();
		for (E aKey : keySet)
			if (key.equals(aKey))
				values.add(map.get(aKey));
		return values;
	}

	public static String join(Collection collection) {
		if (collection == null)
			return null;
		StringBuilder builder = new StringBuilder();
		for (Object object : collection)
			builder.append(object);
		return builder.toString();
	}

}
